#include <iostream>
using namespace std;
#include "bstree.hpp"
#include <vector>
using namespace zq;
#include<string>

void test_dict(){
  BSTree<string,string> dict;
  dict.insert("sort","排序");
  dict.insert("string","字符串");
  dict.insert("tree","树");
  dict.insert("insert","插入");

  string str;
  while(cin>>str){
    //通过key去找value
    BSTree_Node<string,string>* ret = dict.find(str);
    if(ret){
      cout<<ret->_value<<endl;
    }else{
      cout<<"无此单词"<<endl;
    }
  }
}

//统计每种水果出现的次数
void test_fruit(){
  string strarr[] = {"西瓜","苹果","香蕉","菠萝","哈密瓜","西瓜","苹果","香蕉","菠萝"};
  BSTree<string,int> count_tree;
  for(auto e : strarr){
    BSTree_Node<string,int>* ret = count_tree.find(e);
    if(ret == nullptr){
      count_tree.insert(e,1);
    }else{
      ret->_value++;
    }
  }
  count_tree.InOrder();
}
int main() {
  //test_dict();
  test_fruit();

  return 0;
}
